package com.oozol.lieluyun.controller;

import com.oozol.lieluyun.entity.DockerContainers;
import com.oozol.lieluyun.entity.DockerImages;
import com.oozol.lieluyun.entity.ResultData;
import com.oozol.lieluyun.service.IDockerService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DockerController {
   @Autowired
   private IDockerService dockerService;

   @GetMapping({"/api/docker/images"})
   public ResultData<List<DockerImages>> getDockerImages(String jobName) throws Exception {
      List<DockerImages> dockerImages = this.dockerService.getDockerImages(jobName);
      ResultData res = new ResultData();
      res.setMsg("操作成功");
      res.setCount(dockerImages.size());
      res.setPage(1);
      res.setData(dockerImages);
      return res;
   }

   @GetMapping({"/api/docker/containers"})
   public ResultData<List<DockerContainers>> getDockerContainers() throws Exception {
      List<DockerContainers> dockerContainers = this.dockerService.getDockerContainers();
      ResultData res = new ResultData();
      res.setMsg("操作成功");
      res.setCount(dockerContainers.size());
      res.setPage(1);
      res.setData(dockerContainers);
      return res;
   }
}
